import React, { Component } from 'react';
type Istate = {
  hasError: boolean;
};
class ErrorBoundary extends React.Component<any, Istate> {
  constructor(props) {
    super(props);
    this.state = { hasError: false };
  }
  static getDerivedStateFromError(error) {
    // Update state so the next render will show the fallback UI.
    console.log('有错误');
    return { hasError: true };
  }
  ssss;
  componentDidCatch(error, info) {
    // You can also log the error to an error reporting service
  }
  render() {
    if (this.state.hasError) {
      console.log('有错误1');
      // You can render any custom fallback UI
      return (
        <div>
          父组件
          {this.state.hasError ? <div>发生了错误</div> : <Comment />}
        </div>
      );
    }
  }
}
class Comment extends Component {
  componentDidMount() {}
  render() {
    return <div>评论管理dasd</div>;
  }
}

export default ErrorBoundary;
